import sys
from hashlib import md5

def main():
    # 检查命令行参数
    if len(sys.argv) < 2 or "-h" in sys.argv:
        print("Usage: md5str <string>")
        return

    # 合并所有输入参数为一个字符串
    input_string = " ".join(sys.argv[1:])

    # 计算 MD5
    hasher = md5()
    hasher.update(input_string.encode('utf-8'))  # 转为字节
    print(hasher.hexdigest())

if __name__ == "__main__":
    main()
